package com.rabbit.producer.service;

import com.rabbit.producer.constant.BrokerMessageStatus;
import com.rabbit.producer.entity.BrokerMessage;

import java.util.List;

/**
 * @author: 顾志杰
 */
public interface MessageStoreService {

    /**
     * 创建一条消息备份
     * @param brokerMessage
     * @return
     */
    public int insert(BrokerMessage brokerMessage);

    /**
     * 发送成功后根据id更新状态未SEND_OK
     * @param messageId
     * @return
     */
    public void succuess(String messageId);



    /**
     * 发送失败后根据id更新状态未SEND_FALL
     * @param messageId
     * @return
     */
    public void failure(String messageId);


    /**
     * 根据状态查询小于当前时间的发送消息集合
     * @param brokerMessageStatus
     * @return
     */
    public List<BrokerMessage> fetchTimeOutMessageForRertry(BrokerMessageStatus brokerMessageStatus);

    /**
     * 根据id查询BrokerMessage
     * @param messageId
     * @return
     */
    public BrokerMessage selectByPrimaryKey(String messageId);


    /**
     * 更新tryCount
     */
    public int updateTryCount(String brokerMessageId);
}
